<script setup lang="ts">
import { request } from '@/api'
import { showSuccessToast } from 'vant'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()

const content = ref('')
const clickLeft = () => {
  console.log('点击返回')
  router.back()
}
const clickRight = async () => {
  const res = await request.patch<JkResponse<User>>('/v1_0/user/profile', { intro: content.value })
  console.log(res)
  const user = jk.getUser()
  user.intro = content.value
  jk.setUser(user)
  showSuccessToast('修改成功')
  router.back()
}
</script>

<template>
  <van-nav-bar
    title="编辑简介"
    right-text="提交"
    :left-arrow="true"
    @click-left="clickLeft()"
    @click-right="clickRight()"
  />
  <div class="d">
    <van-field v-model="content" class="infroInput" />
  </div>
</template>
<style>
.d {
  padding-top: 10px;
  margin: 10px;
}
.infroInput {
  background-color: rgb(226, 229, 231);
  height: 80px;
  border-radius: 10px;
}
</style>
